<?php 
header('Content-Type: text/html; charset=UTF-8');
ini_set('display_errors' , 1);
ini_set('default_charset', 'UTF-8' );
error_reporting(E_ALL);
session_start();

global $_SESSION;
global $_POST;

// define the autoloader
include_once 'application/library/framework/util/Loader.class.php';
spl_autoload_register(array('Loader', 'autoload'));

// read configurations
$ini  = parse_ini_file('application/config/application.ini');
date_default_timezone_set($ini['timezone']);
//Translator::setLanguage( $ini['language'] );

// define constants
define('APPLICATION_NAME', $ini['application']);
define('ALLOW_URLS', serialize($ini['allow_urls']));
define('TEMPLATE_PATH', $ini['theme']);
define('TEMPLATE_CUSTOM_JS_PATH', $ini['theme']."/assets/scripts");
define('SERVER_NAME', $ini['server']);
define('OS', strtoupper(substr(PHP_OS, 0, 3)));
define('PATH', dirname(__FILE__));
define('VIEW_PATH',$ini['view_path']);

//Error
set_error_handler(array('Application', 'ErrorHandler'));

//Application run
$application = new Application();
$application->addControllerPluginBeforeDispatch("Authenticate", "preDispatch");
$application->addControllerPluginBeforeDispatch("Authorization", "preDispatch");
$application->run();
exit;

?>